﻿using System;
using System.Collections.Generic;
using System.Text;
using CYTools.Util;
using System.Data;
using System.Data.SqlClient;
using CYTools.Models.Model;

namespace CYTools.Models.Dao
{
    public class ProjectInfoDao
    {
        public Database db = new Database();
        /// <summary>
        /// 获取工程信息
        /// </summary>
        /// <param name="conn"></param>
        /// <returns></returns>
        public List<ProjectInfo> getPjInfoList(SqlConnection conn)
        {
            List<ProjectInfo> PjInfoList = new List<ProjectInfo>();
            string sql = "SELECT Gcxx_id,Daima,Mingcheng,Kehu_id,DiZhi,LXR,LXFS  FROM ProjectInfo where Gcxx_id <>1 order by Gcxx_id desc";
            try
            {
                DataTable dt = db.Squery(sql, conn);
                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        ProjectInfo ui = new ProjectInfo();
                        ui.Gcxx_id = row["Gcxx_id"].ToString();
                        ui.Daima = row["Daima"].ToString();
                        ui.Mingcheng = row["Mingcheng"].ToString();
                        ui.Kehu_id = row["Kehu_id"].ToString();
                        ui.DiZhi = row["DiZhi"].ToString();
                        ui.LXR = row["LXR"].ToString();
                        ui.LXFS = row["LXFS"].ToString();
                        PjInfoList.Add(ui);
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            return PjInfoList;
        }

        /// <summary>
        /// 获取工程窗型信息
        /// </summary>
        /// <param name="conn"></param>
        /// <returns></returns>
        public List<ProjectWindow> getPjwInfoList(SqlConnection conn, string Gcxx_id)
        {
            List<ProjectWindow> PjwInfoList = new List<ProjectWindow>();
            string sql = "SELECT Gcmc_id,Gcxx_id,Daima,Shuliang,Chang,Kuan,MianJi  FROM ProjectWindow where Gcxx_id = " + Gcxx_id ;
            try
            {
                DataTable dt = db.Squery(sql, conn);
                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        ProjectWindow ui = new ProjectWindow();
                        ui.Gcmc_id = row["Gcmc_id"].ToString();
                        ui.Gcxx_id = row["Gcxx_id"].ToString();
                        ui.Daima = row["Daima"].ToString();
                        ui.Daima = row["Daima"].ToString();
                        ui.Shuliang = row["Shuliang"].ToString();
                        ui.Chang = row["Chang"].ToString();
                        ui.Kuan = row["Kuan"].ToString();
                        ui.MianJi = row["MianJi"].ToString();
                        PjwInfoList.Add(ui);
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            return PjwInfoList;
        }
        /// <summary>
        /// 获取工程窗型详细信息
        /// </summary>
        /// <param name="conn"></param>
        /// <returns></returns>
        public List<ProjectWindowDetail> getPjwDInfoList(SqlConnection conn, string Gcmc_id)
        {
            List<ProjectWindowDetail> PjwDInfoList = new List<ProjectWindowDetail>();
            string sql = "SELECT Mcmx_id,Gcmc_id,Tk_id,Xl_id,YanseJiage_id,BoLiZhongLei,Pj_CJ_ID  FROM ProjectWindowDetail  where Gcmc_id = " + Gcmc_id;
            try
            {
                DataTable dt = db.Squery(sql, conn);
                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        ProjectWindowDetail ui = new ProjectWindowDetail();
                        ui.Mcmx_id = row["Mcmx_id"].ToString();
                        ui.Gcmc_id = row["Gcmc_id"].ToString();
                        ui.Tk_id = row["Tk_id"].ToString();
                        ui.Xl_id = row["Xl_id"].ToString();
                        ui.YanseJiage_id = row["YanseJiage_id"].ToString();
                        ui.BoLiZhongLei = row["BoLiZhongLei"].ToString();
                        ui.Pj_CJ_ID = row["Pj_CJ_ID"].ToString();
                        PjwDInfoList.Add(ui);
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            return PjwDInfoList;
        }
        /// <summary>
        /// 获取工程窗型详细型材下料信息
        /// </summary>
        /// <param name="conn"></param>
        /// <returns></returns>
        public List<XcXlInfo> getXcXlInfoList(SqlConnection conn, string Mcmx_id)
        {
            List<XcXlInfo> XcXlInfoList = new List<XcXlInfo>();
            string sql = "SELECT Xcxl_id, Mcmx_id,Xc_id,Changdu,ShuLiang,Gcxx_ID,Dir,XcGs_ID  FROM XingCaiXiaLiao  where Mcmx_id = " + Mcmx_id;
            try
            {
                DataTable dt = db.Squery(sql, conn);
                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        XcXlInfo ui = new XcXlInfo();
                        ui.Xcxl_id = row["Xcxl_id"].ToString();
                        ui.Mcmx_id = row["Mcmx_id"].ToString();
                        ui.Xc_id = row["Xc_id"].ToString();
                        ui.Changdu = row["Changdu"].ToString();
                        ui.ShuLiang = row["ShuLiang"].ToString();
                        ui.Gcxx_ID = row["Gcxx_ID"].ToString();
                        ui.Dir = row["Dir"].ToString();
                        ui.XcGs_ID = row["XcGs_ID"].ToString();
                        XcXlInfoList.Add(ui);
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            return XcXlInfoList;
        }
        /// <summary>
        /// 获取工程窗型详细配件下料信息
        /// </summary>
        /// <param name="conn"></param>
        /// <returns></returns>
        public List<PjXlInfo> getPjXlInfoList(SqlConnection conn, string Mcmx_id)
        {
            List<PjXlInfo> PjXlInfoList = new List<PjXlInfo>();
            string sql = "SELECT Pjxl_id, Mcmx_id,Pj_id,Shuliang  FROM PeiJianXiaLiao  where Mcmx_id = " + Mcmx_id;
            try
            {
                DataTable dt = db.Squery(sql, conn);
                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        PjXlInfo ui = new PjXlInfo();
                        ui.Pjxl_id = row["Pjxl_id"].ToString();
                        ui.Mcmx_id = row["Mcmx_id"].ToString();
                        ui.Pj_id = row["Pj_id"].ToString();
                        ui.Shuliang = row["Shuliang"].ToString();
                        PjXlInfoList.Add(ui);
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            return PjXlInfoList;
        }
        /// <summary>
        /// 获取工程窗型详细玻璃下料信息
        /// </summary>
        /// <param name="conn"></param>
        /// <returns></returns>
        public List<BlXlInfo> getBlXlInfoList(SqlConnection conn, string Mcmx_id)
        {
            List<BlXlInfo> BlXlInfoList = new List<BlXlInfo>();
            string sql = "SELECT Blxl_id, Mcmx_id,Changdu,Kuandu,Shuliang,WinBLZL,BLFee,BLYS  FROM BoLiXiaLiao  where Mcmx_id = " + Mcmx_id;
            try
            {
                DataTable dt = db.Squery(sql, conn);
                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        BlXlInfo ui = new BlXlInfo();
                        ui.Blxl_id = row["Blxl_id"].ToString();
                        ui.Mcmx_id = row["Mcmx_id"].ToString();
                        ui.Changdu = row["Changdu"].ToString();
                        ui.Kuandu = row["Kuandu"].ToString();
                        ui.Shuliang = row["Shuliang"].ToString();
                        ui.WinBLZL = row["WinBLZL"].ToString();
                        ui.BLFee = row["BLFee"].ToString();
                        ui.BLYS = row["BLYS"].ToString();
                        BlXlInfoList.Add(ui);
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            return BlXlInfoList;
        }
    }
}
